<?php

namespace App\Models;

use App\Exceptions\InvalidRequestException;
use Illuminate\Database\Eloquent\Model;

class ProductSku extends Model
{
    protected $fillable=[
        'title',
        'description',
        'price',
        'stock',
    ];
    public function product(){
        return $this->belongsTo(Product::class);
    }
    public function decreaseStock($amount){
        return $this->whereRaw('id=? and stock>=?', [$this->id, $amount])->decrement('stock', $amount);
    }
    public function increaseStock($amount){
        return $this->increment('stock', $amount);
    }
}
